﻿using System;

public class WS_Key
{
   #region Properties
   string userid = "";
   public string UserID
   {
      get
      {
         return userid;
      }
      set
      {
         userid = value.ToLower();
      }
   }
   string appid = "";
   public string AppID
   {
      get
      {
         return appid;
      }
      set
      {
         appid = value.ToLower();
      }
   }
   public DateTime TimeStamp = new DateTime(0);
   public string strTimeStamp = "";
   public bool isValid = false;
   public string ApplicationData = "";
   public void SetTime(DateTime Time)
   {
      TimeStamp = Time;
      strTimeStamp = TimeStamp.ToString("yyyy-MM-dd HH:mm:ss");
   }
   public void SetTime(string Time)
   {
      SetTime(Typecast.ToDateTime(Time));
   }
   #endregion

   public string Key = "Do8OikbcRh8=";
   public string IV = "Cg8CDwQLDA0=";
   public string Delimiter = "+";

   public WS_Key() { TimeStamp = DateTime.Now; strTimeStamp = TimeStamp.ToString("yyyy-MM-dd HH:mm:ss"); }

   #region ToString
   public override string ToString()
   {
      return TripleDes.Encrypt_ToBase64(String.Format("{0}{3}{1}{3}{2}",
         UserID,
         AppID,
         TimeStamp.ToString("yyyy-MM-dd HH:mm:ss"),
         Delimiter), Key, IV);
   }

   public string OriginalString
   {
      get
      {
         return String.Format("[{0}]{3}[{1}]{3}[{2}]{3}[{4}]{3}[{5}]",
         UserID,
         AppID,
         TimeStamp.ToString("yyyy-MM-dd HH:mm:ss"),
         ".....",
         strTimeStamp,
         ApplicationData);
      }
   }
   #endregion
}